﻿
namespace Anycmd.Host
{
    using Anycmd.AC;
    using Model;
    using System;

    /// <summary>
    /// 表示静态职责分离角色业务实体。
    /// </summary>
    public sealed class SSDRoleState : StateObject<SSDRoleState>, ISSDRole, IStateObject
    {
        private Guid _ssdSetID;
        private Guid _roleID;
        private DateTime? _createOn;

        private SSDRoleState(Guid id) : base(id) { }

        public static SSDRoleState Create(SSDRoleBase ssdRole)
        {
            return new SSDRoleState(ssdRole.Id)
            {
                _roleID = ssdRole.RoleID,
                _ssdSetID = ssdRole.SSDSetID,
                _createOn = ssdRole.CreateOn
            };
        }

        public Guid SSDSetID
        {
            get { return _ssdSetID; }
        }

        public Guid RoleID
        {
            get { return _roleID; }
        }

        public DateTime? CreateOn
        {
            get { return _createOn; }
        }

        protected override bool DoEquals(SSDRoleState other)
        {
            return Id == other.Id &&
                SSDSetID == other.SSDSetID &&
                RoleID == other.RoleID;
        }
    }
}
